package com.kymatrix.mpo.plus.bpm.server.flowable.candidate.strategy;

import com.kymatrix.mpo.plus.bpm.server.flowable.candidate.BpmTaskCandidateStrategy;
import com.kymatrix.mpo.plus.bpm.server.flowable.enums.BpmTaskCandidateStrategyEnum;
import com.kymatrix.mpo.plus.system.api.service.UserApi;
import com.kymatrix.mpo.plus.common.util.StrUtils;
import java.util.Set;
import javax.annotation.Resource;
import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;

/**
 * 用户 {@link BpmTaskCandidateStrategy} 实现类
 *
 * @author kyle
 */
@Component
public class BpmTaskCandidateUserStrategy implements BpmTaskCandidateStrategy {

    @Resource
    private UserApi userApi;

    @Override
    public BpmTaskCandidateStrategyEnum getStrategy() {
        return BpmTaskCandidateStrategyEnum.USER;
    }

    @Override
    public void validateParam(String param) {
        userApi.validateUserList(StrUtils.splitToStringSet(param));
    }

    @Override
    public Set<String> calculateUsers(DelegateExecution execution, String param) {
        return StrUtils.splitToStringSet(param);
    }

}
